package com.mystudy.concurrent.singleton;

/**
 * TODO: 使用双重检查锁，跟volatile关键字
 *
 * @author acy
 * @since 2019/05/16 13:42
 */
public class SingletonObjectOne {

	private static volatile SingletonObjectOne instance;

	private SingletonObjectOne() {
	}

	//双重检查锁
	public static SingletonObjectOne getInstance() {
		if (null == instance){
			synchronized (SingletonObjectOne.class){
				if (null==instance){
					instance=new SingletonObjectOne();
				}
			}
		}
		return SingletonObjectOne.instance;
	}
}
